package com.systemsjr.mpf.db;

import android.content.ContentValues;
import android.content.Context;
import android.content.Intent;
import android.database.Cursor;

import com.systemsjr.mpf.expense.ExpenseType;

public class ExpenseTypeConnector {
	public static Cursor getAllExpenseTypes(Context context){
		
		return getExpenseType(context, "");
	}
	
	public static Cursor getExpenseType(Context context, String where){
		MpfConnector connector = new MpfConnector(context);
		
		return connector.get(ExpenseType.TABLE_NAME, new String[]{
				ExpenseType.ID,
				ExpenseType.CODE,
				ExpenseType.EXPENSE_TYPE
		}, where);
	}
	
	public static void saveExpenseType(Context context, Intent intent, long rowId, ContentValues contentValues) {
		MpfConnector connector = new MpfConnector(context);

		if (intent.getExtras() == null) {			
			connector.insert(ExpenseType.TABLE_NAME, null, contentValues);
		} else {			
			connector.update(ExpenseType.TABLE_NAME, contentValues, rowId);
		}
	}
}
